﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms; 
using CourseArraging.Common;

namespace CourseArraging.Frm.jxgl
{
    /// <summary>
    /// 版权所有
    /// 石世特@温州医学院 sst330381@gmail.com
    /// </summary> 
    public partial class FrmWXYlist : FrmToolbarBase
    {
        // Fields
        private IContainer components;
        private DataGridView dataGridView1;
        private static FrmWXYlist instance;
        private XyService.XyServiceClient xyDAO=new XyService.XyServiceClient();
        string strWhere = null;

        public FrmWXYlist(string tmpstr)
        {
            this.ImeMode = System.Windows.Forms.ImeMode.OnHalf;
            this.components = null; 
            this.InitializeComponent();
            this.strWhere = tmpstr;
            this.showData();
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                FrmWXyinfo frm = new FrmWXyinfo(int.Parse(this.dataGridView1.Rows[e.RowIndex].Cells["协议流水"].Value.ToString()));
                frm.reflist += new FrmWXyinfo.refreshlist(frm_reflist);
                frm.ShowDialog();
            }
        }

        void frm_reflist()
        {
            showData();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmWXYlist_Load(object sender, EventArgs e)
        {
            this.dataGridView1.CellDoubleClick += new DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
        }

        public static FrmWXYlist GetInstance(string tmpstr)
        {
            if ((instance == null) || instance.IsDisposed)
            {
                instance = new FrmWXYlist(tmpstr);
                instance.MdiParent = GlobalVar.frmMain;
            }
            instance.BringToFront();
            return instance;
        }

        private void InitializeComponent()
        {
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // dataGridView1
            // 
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.AllowUserToDeleteRows = false;
            this.dataGridView1.AllowUserToOrderColumns = true;
            dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
            this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
            this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
            this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLight;
            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dataGridView1.Location = new System.Drawing.Point(0, 44);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.ReadOnly = true;
            this.dataGridView1.RowHeadersWidth = 4;
            this.dataGridView1.RowTemplate.Height = 23;
            this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            this.dataGridView1.Size = new System.Drawing.Size(924, 447);
            this.dataGridView1.TabIndex = 19;
            // 
            // FrmWXYlist
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.ClientSize = new System.Drawing.Size(924, 491);
            this.Controls.Add(this.dataGridView1);
            this.Name = "FrmWXYlist";
            this.Text = "协议列表";
            this.Load += new System.EventHandler(this.FrmWXYlist_Load);
            this.Controls.SetChildIndex(this.dataGridView1, 0);
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        public void showData()
        {
            this.dataGridView1.DataSource = this.xyDAO.GetList(strWhere);
        }

        public override void tsb_new_fun()
        {
            FrmQdxy.GetInstance().Show();
        }
    }
}
